package com.samecity.mvp.view.activity.DomeActivity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.samecity.R;


public class DomeActivity extends Activity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dome);
        initView();
    }
    private void initView(){
        ListView listView  = findViewById(R.id.id_list);
        listView.setAdapter(new ListAdapter());
        //下面设置悬浮和头顶部分内容
        final View header = View.inflate(this, R.layout.adapter__dome_list, null);//头部内容,会隐藏的部分
        listView.addHeaderView(header);//添加头部
        final View header2 = View.inflate(this, R.layout.adapter__dome_lists, null);//头部内容,一直显示的部分
        listView.addHeaderView(header2);//添加头部
        final LinearLayout invis = (LinearLayout) findViewById(R.id.id_ll);

        listView.setOnScrollListener(new AbsListView.OnScrollListener() {

            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (firstVisibleItem >= 1) {
                    invis.setVisibility(View.VISIBLE);
                } else {
                    invis.setVisibility(View.GONE);
                }
            }
        });
    }

    class ListAdapter extends BaseAdapter{

        @Override
        public int getCount() {
            return 20;
        }

        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            view = LayoutInflater.from(DomeActivity.this).inflate(R.layout.adapter__dome_list,null);
            return view;
        }
    }
}
